package sample;

import javafx.geometry.Insets;
import javafx.scene.canvas.Canvas;
import javafx.scene.control.Label;

import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;



public class FirstAnchorPane {


    public AnchorPane firstAnchorPane() throws Exception{
        if(BeautyMain.themeURL==""||BeautyMain.themeURL==null){
            return new AnchorPane();
        }
        AnchorPane anchorPane = new AnchorPane();
        String relativePath = BeautyMain.themeURL+"\\vivo\\vigour_window_bg_dark.9.png";
        Canvas imageView =   BlackBorder.get9NewImageCanvas(relativePath,1080,1920);
        TopPart topPart = new TopPart();
        anchorPane.getChildren().addAll(imageView,topPart.anchorPaneTopPart(),centrAndBottom());
//            anchorPane.setPrefWidth(480);
//            anchorPane.setMaxWidth(480);
//            anchorPane.setMinWidth(480);
        SetSize.SetElementSize(anchorPane,480,854);
        return  anchorPane;
    }

    public HBox centrAndBottom()throws Exception{
        HBox hBox = new HBox();
        VBox vBox = new VBox();

        vBox.setPadding(new Insets(30,0,0,0));
        VBox vBox1 = new VBox();
        vBox1.getChildren().addAll( chatTime(),Myattitude());
        vBox1.setPadding(new Insets(65,0,0,0));
        VBox vBox2 = new VBox();
        vBox2.getChildren().addAll(chatTime(),NotReplace());
        vBox2.setPadding(new Insets(100,0,0,0));
        vBox.getChildren().addAll(editor(),call(),vBox1,vBox2,Send());//
        //vBox.setMargin(editor(),new Insets(0,0,0,0));
        hBox.getChildren().addAll(vBox);
        //hBox.setStyle("-fx-background-color: red");
        hBox.setMaxWidth(480);
        hBox.setMinWidth(480);
        hBox.setPrefWidth(480);
        return  hBox;
    }



    public VBox editor()throws Exception{

        VBox vBox = new VBox();
       // vBox.setStyle("-fx-background-color: green");
        HBox hBox = new HBox();
        hBox.setPrefWidth(480);
        hBox.setPrefHeight(50);
        //hBox.setStyle("-fx-background-color: red");
        HBox leftBox = new HBox();
        String relativePath = BeautyMain.themeURL+"\\vivo\\vigour_btn_title_back_center_contact_normal_light.9.png";//参数是假的
        Canvas imageView =   BlackBorder.get9NewImageCanvas(relativePath,120,120);
//        imageView.setHeight(55);
//        imageView.setWidth(55);

        leftBox.getChildren().addAll(imageView);

        HBox centerBox = new HBox();
        Label label = new Label();
        label.setText("糖糖");
        Font font = new Font("黑体",23);
        String url = BeautyMain.themeURL+"\\vivo\\theme_values.xml";
        String param = "windowTitleColor";
        String colorFont =   DOM4JTest.attrValue(url,param);
        label.setTextFill(Color.web("rgba("+colorFont+")"));

        label.setFont(font);
        //centerBox.setPadding(new Insets(15,0,0,85));
        centerBox.setMargin((label),new Insets(15,0,0,90));
        centerBox.getChildren().addAll(label);


        url = BeautyMain.themeURL+"\\vivo\\theme_values.xml";
        param = "windowTitleColor";

        colorFont =   DOM4JTest.attrValue(url,param);

        HBox rightBox = new HBox();
        Label label1 = new Label();
        label1.setText("编辑");
        label1.setFont(font);
        label1.setTextFill(Color.web("rgba("+colorFont+")"));
        //rightBox.setPadding(new Insets(15,0,0,160));
        rightBox.setMargin(label1,new Insets(15,0,0,165));
        rightBox.getChildren().addAll(label1);

        // hBox.setPadding(new Insets(0,0,0,0));
        AnchorPane anchorPane = new AnchorPane();
        String relativePath1 = BeautyMain.themeURL+"\\com.android.dialer\\activity_title_bar_44.9.png";//参数是假的
        Canvas imageView1 =   BlackBorder.get9NewImageCanvas(relativePath1,1080,120);
        //imageView1.setHeight(120);
        hBox.getChildren().addAll(leftBox,centerBox,rightBox);
        anchorPane.getChildren().addAll(imageView1,hBox);
        vBox.getChildren().addAll(anchorPane);
        SetSize.SetElementSize(vBox,480,120);

        vBox.setPadding(new Insets(-2,0,0,0));

        return vBox;
    }

    public HBox call() throws Exception{
        HBox hBox = new HBox();
       // hBox.setStyle("-fx-background-color: red");
        AnchorPane anchorPane = new AnchorPane();
        hBox.setPrefHeight(55);
        hBox.setPrefWidth(480);
        String relativePath = BeautyMain.themeURL+"\\com.android.mms\\compose_head_bg.9.png";
        Canvas imageView =   BlackBorder.get9ImageCanvas(relativePath,480,59,1.0f,0.8f);

        relativePath =BeautyMain.themeURL+"\\vivo\\vigour_btn_default_normal_light.9.png";
        Canvas imageView1 = BlackBorder.get9ImageCanvas(relativePath,480,114,0.46f,0.35f);

        HBox hBox1 = new HBox();
        AnchorPane anchorPane1 = new AnchorPane();
        Label label = new Label();
        label.setText("呼叫");
        Font font = new Font("黑体",20);
        String url = BeautyMain.themeURL+"\\vivo\\theme_values.xml";
        String param = "text_normal_color";
        String colorFont =   DOM4JTest.attrValue(url,param);
        // label.setTextFill(Color.BLACK);
        label.setTextFill(Color.web("rgba("+colorFont+")"));
        label.setFont(font);
        HBox hBox3 = new HBox();
        hBox3.getChildren().add(label);
        //label.setPadding(new Insets(10,0,0,100));
        hBox3.setMargin(label,new Insets(7,0,0,90));

        anchorPane1.getChildren().addAll(imageView1,hBox3);
        hBox1.getChildren().add(anchorPane1);
        // hBox1.setPadding(new Insets(0,30,0,0));
        //HBox.setMargin(hBox1,new Insets(0,0,0,20));
        hBox1.setPadding(new Insets(5,0,0,10));


        HBox hBox2 = new HBox();
        Canvas imageView2 = BlackBorder.get9ImageCanvas(relativePath,480,114,0.46f,0.35f);
        Label label1 = new Label();
        label1.setText("查看联系人");
        HBox hBox4 = new HBox();
        hBox4.getChildren().add(label1);
        label1.setPadding(new Insets(5,0,0,70));
        //HBox.setMargin(label1,new Insets(5,0,0,70));
        //label1.setPadding(new Insets(0,0,0,20));
        url = BeautyMain.themeURL+"\\vivo\\theme_values.xml";
        param = "text_normal_color";
        colorFont =   DOM4JTest.attrValue(url,param);
        label1.setTextFill(Color.web("rgba("+colorFont+")"));
        label1.setFont(font);
//        imageView2.setWidth(214);
//        imageView2.setHeight(39);
        AnchorPane anchorPane2 = new AnchorPane();
        anchorPane2.getChildren().addAll(imageView2,hBox4);
        hBox2.getChildren().add(anchorPane2);
        hBox2.setPadding(new Insets(5,0,0,235));

        //hBox1.getChildren().addAll(imageView1);
        anchorPane.getChildren().addAll(imageView,hBox1,hBox2);
        hBox.getChildren().addAll(anchorPane);
        //hBox.setPadding(new Insets(-70,0,0,0));
        //.setMargin(hBox,new Insets(-70,0,0,0));
        HBox hBox5 = new HBox();
        hBox5.getChildren().add(hBox);
        hBox5.setMargin(hBox,new Insets(-70,0,0,0));
        //hBox5.setStyle("-fx-background-color: red");
      SetSize.SetElementSize(hBox,480,50);
        return hBox5;
    }

    public VBox chatTime() throws Exception{
        VBox vBox = new VBox();
        Label label = new Label();
        label.setText("1月12日");
        Font font = new Font("黑体",14);
        label.setFont(font);
        String url = BeautyMain.themeURL+"\\com.android.mms\\theme_values.xml";
        String param = "date_font_color";
        String colorFont =   DOM4JTest.attrValue(url,param);
        label.setTextFill(Color.web("rgba("+colorFont+")"));


        vBox.setPadding(new Insets(-80,0,0,210));
        vBox.getChildren().add(label);
        //vBox.setStyle("-fx-background-color: red");
        return vBox;
    }


    public VBox Myattitude() throws Exception{
        VBox vBox = new VBox();
        AnchorPane anchorPane = new AnchorPane();
        String relativePath = BeautyMain.themeURL+"\\com.android.mms\\sms_left_bg.9.png";
        Canvas imageView =   BlackBorder.get9ImageCanvas(relativePath,800,500,0.44f,0.4f);
        anchorPane.getChildren().add(imageView);
        anchorPane.setPadding(new Insets(10,0,0,10));
        //anchorPane.setStyle("-fx-background-color: red");
        vBox.getChildren().add(anchorPane);
        vBox.setMargin(anchorPane,new Insets(10,0,0,10));
        Label label = new Label();
        Label label2 = new Label();
        Label label3 = new Label();
        Label label4 = new Label();
        VBox vBox1 = new VBox();

        label.setText("你好,很喜欢你们的设计呢～期");
        //label.setPadding(new Insets(10,0,0,0));
        label2.setText("待每周都新主题出来,希望会有");
        label2.setPadding(new Insets(10,0,0,0));
        label3.setText("很多类型主题呢～加油～");
        label3.setPadding(new Insets(10,0,0,0));
        label4.setText("10:15");
        label4.setPadding(new Insets(15,0,0,235));
        vBox1.getChildren().addAll(label,label2,label3,label4);
        vBox1.setPadding(new Insets(40,0,0,45));

        anchorPane.getChildren().addAll(vBox1);
        Font font = new Font("黑体",21);
        label.setFont(font);
        label2.setFont(font);
        label3.setFont(font);
        font = new Font("黑体",16);
        String url = BeautyMain.themeURL+"\\com.android.mms\\theme_values.xml";
        label4.setFont(font);
        String param = "from_context_font_color";
        String colorFont =   DOM4JTest.attrValue(url,param);
        label.setTextFill(Color.web("rgba("+colorFont+")"));
        label2.setTextFill(Color.web("rgba("+colorFont+")"));
        label3.setTextFill(Color.web("rgba("+colorFont+")"));
        label4.setTextFill(Color.web("rgba("+colorFont+")"));


        vBox.setPadding(new Insets(-70,0,0,10));
        //vBox.setStyle("-fx-background-color: red");
        vBox.setPrefWidth(480);
        vBox.setMinWidth(480);
        vBox.setMaxWidth(480);
        return  vBox;
    }

    public VBox NotReplace() throws Exception{
        VBox vBox = new VBox();
        VBox vBox1 = new VBox();
        AnchorPane anchorPane = new AnchorPane();
        String relativePath = BeautyMain.themeURL+"\\com.android.mms\\sms_right_bg.9.png";
        Canvas imageView =   BlackBorder.get9ImageCanvas(relativePath,800,400,0.45,0.4f);
//        anchorPane.getChildren().add();
        vBox.getChildren().add(anchorPane);
        Font font = new Font("黑体",21);
        Label label = new Label();
        label.setText("您好,非常感谢您的喜欢～我们");
        label.setFont(font);
        Label label2 = new Label();
        label2.setText("会继续努力呢^ω^");
        label2.setFont(font);
        Label label3 = new Label();
        label3.setText("05:30");
        font = new Font("黑体",16);
        label3.setFont(font);
        label3.setPadding(new Insets(15,0,0,235));
        String url = BeautyMain.themeURL+"\\com.android.mms\\theme_values.xml";
        String param = "context_font_color";
        String colorFont =   DOM4JTest.attrValue(url,param);
        label.setTextFill(Color.web("rgba("+colorFont+")"));
        label2.setTextFill(Color.web("rgba("+colorFont+")"));
        label3.setTextFill(Color.web("rgba("+colorFont+")"));
        vBox1.setPadding(new Insets(40,0,0,40));
        vBox1.getChildren().addAll(label,label2,label3);
        anchorPane.getChildren().addAll(imageView,vBox1);
        vBox.setPadding(new Insets(-60,0,0,100));
        //vBox.setStyle("-fx-background-color: red");
        vBox.setMinWidth(480);
        vBox.setPrefWidth(480);
        vBox.setMaxWidth(480);
        return vBox;
    }

    public VBox Send() throws Exception{
        VBox vBox = new VBox();
        HBox hBox = new HBox();

        VBox left = new VBox();
        String relativePath = BeautyMain.themeURL+"\\com.android.mms\\compose_add_attachment.png";
        Canvas imageView =   BlackBorder.get9NewImageCanvas(relativePath,70,70);
        left.getChildren().add(imageView);
//        imageView.setHeight(100);
//        imageView.setWidth(100);
        left.setPadding(new Insets(5,0,0,20));

        VBox center = new VBox();
        relativePath = BeautyMain.themeURL+"\\com.android.mms\\edittext_bg.9.png";
        Canvas imageView2 =   BlackBorder.get9ImageCanvas(relativePath,1080,92,0.32f,0.38);
        AnchorPane anchorPane = new AnchorPane();
//        anchorPane.getChildren().addAll();
        //center.getChildren().add();
        String url = BeautyMain.themeURL+"\\com.android.mms\\theme_values.xml";
        String param = "attachment_name_text_color";
        String colorFont =   DOM4JTest.attrValue(url,param);
        Label label1 = new Label();
        Font font = new Font("黑体",20);
        label1.setFont(font);
        label1.setText("输入内容");
        label1.setPadding(new Insets(5,0,0,10));
        anchorPane.getChildren().addAll(imageView2,label1);
        center.getChildren().addAll(anchorPane );
        url = BeautyMain.themeURL+"\\com.android.mms\\theme_values.xml";
        param = "compose_send_text_color";
        colorFont =   DOM4JTest.attrValue(url,param);
        center.setPadding(new Insets(0,0,0,-30));

        VBox myright = new VBox();
        Label label2 = new Label();
        label2.setText("发送");
        font = new Font("微软雅黑",20);
        label2.setFont(font);
        label2.setTextFill(Color.web("rgba("+colorFont+")"));
        myright.getChildren().addAll(label2);
        myright.setPadding(new Insets(2,0,0,10));
        myright.setMargin(label2,new Insets(3,0,0,0));
        AnchorPane anchorPane1 = new AnchorPane();
        String relativePath3 = BeautyMain.themeURL+"\\com.android.mms\\compose_bottom_bg.9.png";
        Canvas imageView3 =   BlackBorder.get9NewImageCanvas(relativePath3,1080,140);

        //myright.setStyle("-fx-background-color: blue");
        hBox.getChildren().addAll(left,center,myright);
        anchorPane1.getChildren().addAll(imageView3,hBox);
        hBox.setPadding(new Insets(13,0,0,0));
        vBox.getChildren().add(anchorPane1);
        vBox.setMargin(anchorPane1,new Insets(8,0,0,0));
        SetSize.SetWidthSize(anchorPane1,480);

        vBox.setPadding(new Insets(219,0,0,0));
        SetSize.SetElementSize(vBox,480,60);
        //anchorPane1.setStyle("-fx-background-color: red");
        return vBox;
    }

}
